<?php
header("Content-Type:image/png");
$image=imagecreatetruecolor(200,100);
$color=imagecolorallocate($image,255,255,0);
imagefill($image,0,0,$color);
//画出随机4位数
for($i=0;$i<50;$i++){
	$color=imagecolorallocate($image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
    imageline($image,mt_rand(0,200),mt_rand(0,100),mt_rand(0,200),mt_rand(0,100),$color);
}
$numstr="";
for($i=0;$i<4;$i++){
	$color=imagecolorallocate($image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
	$num=mt_rand(0, 9);
	imagettftext($image,30,mt_rand(-40, 40),20+$i*50,70,$color,"msyh.ttc",$num);
	$numstr.=$num;
}
session_start();
$_SESSION["imageNum"]=$numstr;
for($i=0;$i<500;$i++){
   $color=imagecolorallocate($image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
	imagesetpixel($image, mt_rand(0, 200),mt_rand(0, 100), $color);
}
imagepng($image);
?>